package com.letv.core.bean;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import android.text.TextUtils;

import com.letv.core.utils.LogInfo;

public class LiveRemenListBean implements LetvBaseBean {
    private static final long serialVersionUID = 1L;
    private List<LiveRemenBaseBean> mRemenList = new ArrayList<LiveRemenBaseBean>();

    public List<LiveRemenBaseBean> getRemenList() {
        return mRemenList;
    }

    public void setRemenList(List<LiveRemenBaseBean> beanList) {
        mRemenList = beanList;
    }

    public void add(LiveRemenBaseBean bean){
        mRemenList.add(bean);
    }

    public void remove(LiveRemenBaseBean bean){
        mRemenList.remove(bean);
    }

    public static class LiveRemenBaseBean implements LetvBaseBean {
        public final static String LIVE_TYPE_SPORT = "letv_live_sports";// 体育
        public final static String LIVE_TYPE_ENT = "letv_live_ent";// 娱乐
        public final static String LIVE_TYPE_MUSIC = "letv_live_music";// 音乐
        public final static String LIVE_TYPE_OTHER = "letv_live_other";// 其他
        public final static String LIVE_TYPE_DEFAULT = "letv_live_default";// 其他

        // 对应status 的三种状态
        /**
         * 未开始
         */
        public static final String PLAY_NO_START = "1";
        /**
         * 直播中
         */
        public static final String PLAY_PLAYING = "2";
        /**
         * 已结束
         */
        public static final String PLAY_OVER = "3";

        public static final String IS_PAY = "1";
        public static final String IS_BOOKED = "1";

        public static final String STATUS_AUTHORED = "1";
        private static final long serialVersionUID = 1L;
        protected String id;    //LiveSports.uniqueId
        protected String type;
        protected String beginTime;
        protected String endTime;
        protected String selectId;
        protected String ch;
        protected String isPay;     //LiveSports.pay
        protected String title;     //LiveSports.name
        protected String liveType;      //LiveSports.ct
        protected String description;
        protected String status;
        protected String recordingId;
        protected String vid;
        protected String pid;
        protected String weight;
        protected String typeICON;
        protected String isVS;
        protected String level1;
        protected String level; //programTypeName
        protected String typeValue;
        
        /**
         * 是否正在播放:0-没有预约，1-已预约
         */
        private String isbooked = null;
        /**
         * 播放时间
         */
        private String play_time = null;
        /**
         * 播放日期
         */
        private String play_date = null;
        private String year;
        
        /*****LiveSports******/
        /**
         * 赛事轮次
         */
        private String match = null;
        /**
         * 主队名称
         */
        private String home = null;
        /**
         * 客队名称
         */
        private String guest = null;
        /**
         * 主队分数
         */
        private String homescore = null;
        /**
         * 客队分数
         */
        private String guestscore = null;
        /**
         * 解说语言
         */
        private String commentaryLanguage = null;
        private String homeImgUrl = null;

        private String guestImgUrl = null;
        private String seanson;
        /*****LiveSports******/
        
        /*****LiveMusic******/
        private String address;
        /*****LiveMusic******/
        
        /*****LiveEnt*******/
        private String isPlayback;
        private String specialPageUrl;
        private String preVID;
        /*****LiveEnt*******/

        public String getScreenings() {
            return screenings;
        }

        public void setScreenings(String screenings) {
            this.screenings = screenings;
        }

        protected String screenings;    //LiveSports.pay

        protected String channelName;

        private String chatRoomNum;
        
        protected boolean authored;// 是否已签权

        public String getChatRoomNum() {
            return chatRoomNum;
        }

        public void setChatRoomNum(String chatRoomNum) {
            this.chatRoomNum = chatRoomNum;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getBeginTime() {
            return beginTime;
        }

        public void setBeginTime(String beginTime) {
            this.beginTime = beginTime;
            setPlay_date(parseDate(beginTime));
            setPlay_time(parseTime(beginTime));
            setYear(parseYear(beginTime));
        }

        public String getEndTime() {
            return endTime;
        }

        public String getChannelName() {
            return channelName;
        }

        public void setChannelName(String channelName) {
            this.channelName = channelName;
        }

        public void setEndTime(String endTime) {
            this.endTime = endTime;
        }

        public String getSelectId() {
            return selectId;
        }

        public void setSelectId(String selectId) {
            this.selectId = selectId;
        }

        public String getCh() {
            return ch;
        }

        public void setCh(String ch) {
            this.ch = ch;
        }

        public String getIsPay() {
            return isPay;
        }

        public void setIsPay(String isPay) {
            this.isPay = isPay;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public boolean isAuthored() {
            return authored;
        }

        public void setAuthored(boolean authored) {
            this.authored = authored;
        }

        public String getTypeValue() {
            return typeValue;
        }

        public void setTypeValue(String typeValue) {
            this.typeValue = typeValue;
        }

        public String getName1() {
            if (LIVE_TYPE_SPORT.equals(ch)) {
                String launguage = TextUtils.isEmpty(getCommentaryLanguage()) ? "" : "[" + getCommentaryLanguage() + "]";
                return getPlayDate() + " " + getPlayTime() + " " +( TextUtils.isEmpty(getLevel1())?"":getLevel1()) + " " + launguage;
            } else if (LIVE_TYPE_ENT.equals(ch)) {
                return getPlay_date() + " " + getPlay_time() + " " + getTypeValue();
            } else if (LIVE_TYPE_MUSIC.equals(ch)) {
                return getPlay_date() + " " + getPlay_time() + " " + getTypeValue();
            }else{
                return "";
            }
        }

        public String getName2() {
            if (LIVE_TYPE_SPORT.equals(ch)) {
                String name2 = null;
                // 体育类型(0-非比赛类,1-比赛类)
                if ("1".equals(getIsVS())) {
                    if ("1".equals(getStatus()) || "2".equals(getStatus())) {
//                      name2 = String.format("<html><head><title></title></head><body><p><font color=\"#00a0e9\">%s</p></body></html>", "vs");
                        name2 = "VS";
                    } else {
//                      name2 = String.format("<html><head><title></title></head><body><p><font color=\"#00a0e9\">%s-%s</p></body></html>",
//                              TextUtils.isEmpty(getHomescore()) ? 0 : getHomescore(), TextUtils.isEmpty(getHomescore()) ? 0 : getGuestscore());
                        name2 = "" + (TextUtils.isEmpty(getHomescore()) ? 0 : getHomescore()) + "-" + (TextUtils.isEmpty(getHomescore()) ? 0 : getGuestscore());
                    }
                } else {
                    name2 = getTitle();
                }
                return name2;
            } else if (LIVE_TYPE_ENT.equals(ch)) {
                return getTitle();
            } else if (LIVE_TYPE_MUSIC.equals(ch)) {
                return getTitle();
            }else{
                return "";
            }
        }

        public String getLiveType() {
            return liveType;
        }

        public void setLiveType(String liveType) {
            this.liveType = liveType;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public String getStatus() {
            return status;
        }

        public void setStatus(String status) {
            this.status = status;
        }

        public String getWeight() {
            return weight;
        }

        public String getPlayDate() {
            if (!TextUtils.isEmpty(beginTime)&&beginTime.length()==19) {
                return beginTime.substring(5, 10);
            }
            return parseDate(beginTime);
        }

        public String getFullPlayDate() {
            return parseFullDate(beginTime);
        }

        public String getPlayTime() {
            if (!TextUtils.isEmpty(beginTime)&&beginTime.length()==19) {
                return beginTime.substring(11, 16);
            }
            return parseTime(beginTime);
        }

        public String getPlayYear() {
            return parseTime(beginTime);
        }

        public void setWeight(String weight) {
            this.weight = weight;
        }

        public String getRecordingId() {
            return recordingId;
        }

        public void setRecordingId(String recordingId) {
            this.recordingId = recordingId;
        }

        public String getVid() {
            return vid;
        }

        public void setVid(String vid) {
            this.vid = vid;
        }

        public String getPid() {
            return pid;
        }

        public void setPid(String pid) {
            this.pid = pid;
        }

        public String getTypeICON() {
            return typeICON;
        }

        public void setTypeICON(String typeICON) {
            this.typeICON = typeICON;
        }

        public String getIsVS() {
            return isVS;
        }

        public void setIsVS(String isVS) {
            this.isVS = isVS;
        }

        public String getLevel1() {
            return level1;
        }

        public void setLevel1(String level1) {
            this.level1 = level1;
        }

        public String getLevel() {
            return level;
        }

        public void setLevel(String level) {
            this.level = level;
        }

        public String getPlay_time() {
            return play_time;
        }

        public void setPlay_time(String play_time) {
            this.play_time = play_time;
        }

        public String getPlay_date() {
            return play_date;
        }

        public void setPlay_date(String play_date) {
            this.play_date = play_date;
        }
        
        public String getYear() {
            return year;
        }

        public void setYear(String year) {
            this.year = year;
        }

        public String getMatch() {
            return match;
        }

        public void setMatch(String match) {
            this.match = match;
        }

        public String getHome() {
            return home;
        }

        public void setHome(String home) {
            this.home = home;
        }

        public String getGuest() {
            return guest;
        }

        public void setGuest(String guest) {
            this.guest = guest;
        }

        public String getHomescore() {
            return homescore;
        }

        public void setHomescore(String homescore) {
            this.homescore = homescore;
        }

        public String getGuestscore() {
            return guestscore;
        }

        public void setGuestscore(String guestscore) {
            this.guestscore = guestscore;
        }

        public String getCommentaryLanguage() {
            return commentaryLanguage;
        }

        public void setCommentaryLanguage(String commentaryLanguage) {
            this.commentaryLanguage = commentaryLanguage;
        }

        public String getHomeImgUrl() {
            return homeImgUrl;
        }

        public void setHomeImgUrl(String homeImgUrl) {
            this.homeImgUrl = homeImgUrl;
        }

        public String getGuestImgUrl() {
            return guestImgUrl;
        }

        public void setGuestImgUrl(String guestImgUrl) {
            this.guestImgUrl = guestImgUrl;
        }

        public String getSeanson() {
            return seanson;
        }

        public void setSeanson(String seanson) {
            this.seanson = seanson;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }
        
        public String getIsPlayback() {
            return isPlayback;
        }

        public void setIsPlayback(String isPlayback) {
            this.isPlayback = isPlayback;
        }

        public String getSpecialPageUrl() {
            return specialPageUrl;
        }

        public void setSpecialPageUrl(String specialPageUrl) {
            this.specialPageUrl = specialPageUrl;
        }

        public String getPreVID() {
            return preVID;
        }

        public void setPreVID(String preVID) {
            this.preVID = preVID;
        }

        public String getIsbooked() {
            return isbooked;
        }

        public void setIsbooked(String isbooked) {
            this.isbooked = isbooked;
        }

        @Override
        public String toString() {
            return "LiveRemenBase [id=" + id + ", type=" + type
                    + ", beginTime=" + beginTime + ", endTime=" + endTime
                    + ", selectId=" + selectId + ", ch=" + ch + ", isPay="
                    + isPay + ", title=" + title + ", liveType=" + liveType
                    + ", description=" + description + ", status=" + status
                    + ", recordingId=" + recordingId + ", vid=" + vid
                    + ", pid=" + pid + ", weight=" + weight + ", typeICON="
                    + typeICON + ", isVS=" + isVS + ", level1=" + level1
                    + ", level=" + level + ", typeValue=" + typeValue
                    + ", channelName=" + channelName + ", chatRoomNum="
                    + chatRoomNum + ", authored=" + authored
                    + "]";
        }

        
        private static SimpleDateFormat sdf_year = new SimpleDateFormat("yyyy");
        private static SimpleDateFormat sdf_all = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        private static SimpleDateFormat sdf_date = new SimpleDateFormat("MM-dd");
        private static SimpleDateFormat sdf_fdate = new SimpleDateFormat("yyyy-MM-dd");
        private static SimpleDateFormat sdf_time = new SimpleDateFormat("HH:mm");

        public static String parseDate(String date_all) {
            try {
                Date date = sdf_all.parse(date_all);
                return sdf_date.format(date);
            } catch (ParseException e) {
                LogInfo.log("wxy", "error when parse date:" + date_all);
            }
            return date_all;
        }

        public static String parseFullDate(String date_all) {
            try {
                Date date = sdf_all.parse(date_all);
                return sdf_fdate.format(date);
            } catch (ParseException e) {
                LogInfo.log("wxy", "error when parse date:" + date_all);
            }
            return date_all;
        }

        public static String parseTime(String date_all) {
            try {
                Date date = sdf_all.parse(date_all);
                return sdf_time.format(date);
            } catch (ParseException e) {
                LogInfo.log("wxy", "error when parse time:" + date_all);
            }
            return date_all;
        }

        public static String parseYear(String date_all) {
            try {
                Date date = sdf_year.parse(date_all);
                return sdf_time.format(date);
            } catch (ParseException e) {
                LogInfo.log("wxy", "error when parse time:" + date_all);
            }
            return date_all;
        }

    }
}
